package com.study.demoevent.event.publisher;

import com.study.demoevent.event.dto.MyEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

/**
 * @Name: PublisherService
 * @Description: java类作用描述
 * @Author: yn
 * @CreateDate: 2022/9/5 16:49
 * @Remark: 特殊说明
 * @Version: 1.0
 */
@Component
public class PublisherService implements ApplicationEventPublisherAware {
    private ApplicationEventPublisher applicationEventPublisher;

    public void publishEvent(String name) {
        applicationEventPublisher.publishEvent(new MyEvent(this,name));
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher=applicationEventPublisher;
    }
}
